package com.xaicode.auth.security.domain;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;

import java.util.Date;
import java.util.List;
import java.util.Objects;

/**
 * 登录者基础信息包装，用于全局获取
 * 
 * @date 2024/12/6
 */
@Data
public class LoginUser {

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date loginTime;
    private String prevLoginIp;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date prevLoginTime;
    private String prevLoginRegion;

    private Integer admin;
    private String userId;
    private String username;
    private String nickname;
    private String avatar;
    private String mobile;
    private String email;
    private Integer sex;
    private String loginIp;
    private String loginRegion;

    private Integer deptId;
    private String deptName;
    /* 例：上海分/研发部 */
    private List<String> deptNames;

    private String browser;
    private String os;

    // ----

    /**
     * 获取数据权限标识
     *
     * @return .
     */
    public String dataScope() {
        if (Objects.nonNull(this.deptId)) {
            return this.deptId.toString();
        }
        return "";
    }
}
